<template>
  <div class="container-content">
    <el-form
      ref="formRef"
      :model="formData"
      :rules="rules"
      size="medium"
      label-width="90px"
      label-position="left"
    >
      <el-dropdown
        style="position: absolute; right: 50px; top: 20px; z-index: 10"
        trigger="click"
        @command="handleCommand"
      >
        <el-button size="small" type="primary">
          选单<i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="payOrder">采购订单</el-dropdown-item>
          <el-dropdown-item command="inOrder">采购入库单</el-dropdown-item>
          <el-dropdown-item command="backOrder">采购退料单</el-dropdown-item>
          <el-dropdown-item command="spilloverOrder"
            >冲红应付单</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
      <el-collapse v-model="activeName" @change="handleChange">
        <el-collapse-item title="基本" name="basic">
          <el-row :gutter="15">
            <el-col :span="24">
              <el-form-item
                label="立账类型"
                prop="kingInvoicePayableEntity.accountType"
              >
                <el-select
                  :disabled="
                    this.sourceDocType === '2' ||
                    formData.kingInvoicePayableEntity.isTicketsBefore === '1'
                  "
                  v-model="formData.kingInvoicePayableEntity.accountType"
                  placeholder="请选择立账类型"
                  clearable
                  :style="{ width: '100%' }"
                >
                  <el-option
                    v-for="(item, index) in accountTypeOptions"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                    :disabled="item.disabled"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="rowId" :span="8">
              <el-form-item
                label="单据类型"
                prop="kingInvoicePayableEntity.docTypeCode"
              >
                <el-input
                  :disabled="true"
                  style="width: 100%"
                  v-model="formData.kingInvoicePayableEntity.docTypeCode"
                  :props="props"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col v-if="!rowId" :span="8">
              <el-form-item
                label="单据类型"
                prop="kingInvoicePayableEntity.docTypeCode"
              >
                <el-select
                  v-model="formData.kingInvoicePayableEntity.docTypeCode"
                  placeholder="请选择"
                  style="width: 100%"
                  @change="handleInvoiceChange"
                >
                  <el-option
                    v-for="item in documentTypeList"
                    :key="item.docCode"
                    :label="item.title"
                    :value="item.docCode"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="供应商"
                prop="kingInvoicePayableEntity.supplierName"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.supplierName"
                  placeholder="请选择供应商"
                  clearable
                  :style="{ width: '100%' }"
                  readonly
                >
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="showDialog('supplier')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="采购员"
                prop="kingInvoicePayableEntity.procureUser"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.procureUser"
                  placeholder="请选择采购员"
                  clearable
                  readonly
                  :style="{ width: '100%' }"
                >
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="showDialog('user')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="单据编号"
                prop="kingInvoicePayableEntity.docNo"
              >
                <el-input
                  disabled
                  v-model="formData.kingInvoicePayableEntity.docNo"
                  placeholder="保存时自动生成"
                  clearable
                  :style="{ width: '100%' }"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="币别"
                prop="kingInvoicePayableEntity.currencyName"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.currencyName"
                  placeholder="请选择币别"
                  clearable
                  readonly
                  :style="{ width: '100%' }"
                >
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="showDialog('currency')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="kingInvoicePayableEntity.rate" label="汇率">
                <el-input
                  v-model="formData.kingInvoicePayableEntity.rate"
                  clearable
                  disabled
                  @change="changeRate"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="结算组织"
                prop="kingInvoicePayableEntity.settlementDept"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.settlementDept"
                  placeholder="请输入结算组织"
                  clearable
                  :style="{ width: '100%' }"
                >
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="showDialog('settlementDeptId')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="业务时间"
                prop="kingInvoicePayableEntity.bizTime"
              >
                <el-date-picker
                  v-model="formData.kingInvoicePayableEntity.bizTime"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  :style="{ width: '100%' }"
                  placeholder="请选择业务时间"
                  clearable
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="价税合计"
                prop="kingInvoicePayableEntity.totalTaxAmount"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.totalTaxAmount"
                  disabled
                  placeholder="请输入价税合计"
                  clearable
                  :style="{ width: '100%' }"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="付款组织"
                prop="kingInvoicePayableEntity.payDeptName"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.payDeptName"
                  placeholder="请输入付款组织"
                  clearable
                  :style="{ width: '100%' }"
                  ><i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="showDialog('payDeptId')"
                  ></i
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="到期日"
                prop="kingInvoicePayableEntity.dueTime"
              >
                <el-date-picker
                  v-model="formData.kingInvoicePayableEntity.dueTime"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  :style="{ width: '100%' }"
                  placeholder="请选择到期日"
                  clearable
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="付款条件"
                prop="kingInvoicePayableEntity.payTermsTitle"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.payTermsTitle"
                  placeholder="请输入付款条件"
                  clearable
                  readonly
                  :style="{ width: '100%' }"
                >
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="showDialog('payTerms')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="采购组织"
                prop="kingInvoicePayableEntity.procureCompany"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.procureCompany"
                  placeholder="请输入采购组织"
                  clearable
                  :style="{ width: '100%' }"
                  ><i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="showDialog('procureCompany')"
                  ></i
                ></el-input>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="8">
              <el-form-item
                label="单据状态"
                prop="kingInvoicePayableEntity.status"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.status"
                  placeholder="请输入单据状态"
                  clearable
                  :style="{ width: '100%' }"
                >
                </el-input>
              </el-form-item>
            </el-col> -->
            <el-col :span="8">
              <el-form-item
                label="采购部门"
                prop="kingInvoicePayableEntity.procureDeptName"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.procureDeptName"
                  placeholder="请输入采购部门"
                  clearable
                  readonly
                  :style="{ width: '100%' }"
                >
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="showDialog('dept')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="整单折扣金额"
                prop="kingInvoicePayableEntity.discountAmount"
                label-width="100px"
              >
                <el-input
                  disabled
                  v-model="formData.kingInvoicePayableEntity.discountAmount"
                  placeholder="请输入整单折扣金额"
                  clearable
                  :style="{ width: '100%' }"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <el-col :span="8">
              <el-form-item
                label="价外税"
                prop="kingInvoicePayableEntity.isExtraPriceTax"
              >
                <el-radio-group
                  v-model="formData.kingInvoicePayableEntity.isExtraPriceTax"
                  size="medium"
                >
                  <el-radio
                    v-for="(item, index) in isExtraPriceTaxOptions"
                    :key="index"
                    :label="item.value"
                    :disabled="item.disabled"
                    border
                    >{{ item.label }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label-width="140px"
                label="按费用项目生成计划"
                prop="kingInvoicePayableEntity.isFee"
              >
                <el-radio-group
                  v-model="formData.kingInvoicePayableEntity.isFee"
                  size="medium"
                >
                  <el-radio
                    v-for="(item, index) in isFeeOptions"
                    :key="index"
                    :label="item.value"
                    :disabled="item.disabled"
                    border
                    >{{ item.label }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label-width="120px"
                label="按含税单价录入"
                prop="kingInvoicePayableEntity.isIncludeTaxPrice"
              >
                <el-radio-group
                  v-model="formData.kingInvoicePayableEntity.isIncludeTaxPrice"
                  size="medium"
                >
                  <el-radio
                    v-for="(item, index) in isIncludeTaxPriceOptions"
                    :key="index"
                    :label="item.value"
                    :disabled="item.disabled"
                    border
                    >{{ item.label }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <el-col :span="8">
              <el-form-item
                label-width="100px"
                label="税额计入成本"
                prop="kingInvoicePayableEntity.isTaxCostAmount"
              >
                <el-radio-group
                  v-model="formData.kingInvoicePayableEntity.isTaxCostAmount"
                  size="medium"
                >
                  <el-radio
                    v-for="(item, index) in isTaxCostAmountOptions"
                    :key="index"
                    :label="item.value"
                    :disabled="item.disabled"
                    border
                    >{{ item.label }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label-width="100px"
                label="先到票后入库"
                prop="kingInvoicePayableEntity.isTicketsBefore"
              >
                <el-radio-group
                  v-model="formData.kingInvoicePayableEntity.isTicketsBefore"
                  size="medium"
                >
                  <el-radio
                    v-for="(item, index) in isTicketsBeforeOptions"
                    :key="index"
                    :label="item.value"
                    :disabled="item.disabled"
                    border
                    >{{ item.label }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item
                label="备注"
                prop="kingInvoicePayableEntity.remarks"
              >
                <el-input
                  v-model="formData.kingInvoicePayableEntity.remarks"
                  type="textarea"
                  placeholder="请输入备注"
                  :autosize="{ minRows: 4, maxRows: 4 }"
                  :style="{ width: '100%' }"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="明细" name="detail">
          <el-button type="text" @click="addNewRow('detail')">新增行</el-button>
          <!-- 费用 -->
          <el-table
            v-if="docType === 'YFD02_SYS'"
            :data="formData.kingInvoicePayableDetailEntities"
            style="width: 100%"
            highlight-current-row
            border
          >
            <el-table-column label="操作" width="120" fixed>
              <template slot-scope="scope">
                <el-button
                  plain
                  icon="el-icon-minus"
                  size="mini"
                  @click="handleDataDelete(scope.$index, scope.row, 'detail')"
                ></el-button>
              </template>
            </el-table-column>
            <el-table-column
              width="150"
              label="序号"
              type="index"
              align="center"
            ></el-table-column>
            <el-table-column width="150" label="费用项目编码">
              <template slot-scope="scope">
                <el-form-item
                  prop="feeCode"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.feeCode" clearable readonly>
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('fee', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="费用项目名称">
              <template slot-scope="scope">
                <el-form-item prop="title" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.title" clearable disabled>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="费用承担部门">
              <template slot-scope="scope">
                <el-form-item
                  prop="feeBearDeptId"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.feeBearDeptId"
                    clearable
                    readonly
                  >
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('feeDept', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="计价单位">
              <template slot-scope="scope">
                <el-form-item prop="unit" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.unit" clearable readonly>
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('unit', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="含税单价">
              <template slot-scope="scope">
                <el-form-item
                  prop="taxPrice"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.taxPrice" clearable> </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="单价">
              <template slot-scope="scope">
                <el-form-item prop="price" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.price" clearable disabled>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="数量">
              <template slot-scope="scope">
                <el-form-item prop="num" label-width="0px" style="margin: 0">
                  <el-input
                    v-model="scope.row.num"
                    clearable
                    @change="caculateNum(scope.row, scope.$index)"
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="税率%">
              <template slot-scope="scope">
                <el-form-item prop="rate" label-width="0px" style="margin: 0">
                  <el-input
                    v-model="scope.row.rate"
                    clearable
                    @change="caculateNum(scope.row, scope.$index)"
                  >
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('rate', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <!-- <el-table-column width="150" label="直接汇率">
              <template slot-scope="scope">
                <el-form-item
                  prop="directRate"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.directRate"
                    clearable
                    @change="caculateNum(scope.row, scope.$index)"
                  >
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('directRate', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="间接汇率">
              <template slot-scope="scope">
                <el-form-item
                  prop="indirectRate"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.indirectRate" clearable disabled>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column> -->
            <el-table-column width="150" label="价税合计">
              <template slot-scope="scope">
                <el-form-item
                  prop="totalTaxPrice"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.totalTaxPrice"
                    clearable
                    @change="
                      caculateNum(scope.row, scope.$index, 'totalTaxPrice')
                    "
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="折扣率%">
              <template slot-scope="scope">
                <el-form-item
                  prop="discountRate"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    @change="discountRateChange(scope.row, scope.$index)"
                    v-model="scope.row.discountRate"
                    clearable
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="税额">
              <template slot-scope="scope">
                <el-form-item
                  prop="rateAmount"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.rateAmount"
                    clearable
                    disabled
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="不含税金额">
              <template slot-scope="scope">
                <el-form-item
                  prop="notTaxAmount"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.notTaxAmount" clearable>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="折扣额">
              <template slot-scope="scope">
                <el-form-item
                  prop="discountAmount"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.discountAmount"
                    clearable
                    disabled
                    @change="
                      caculateNum(scope.row, scope.$index, 'discountAmount')
                    "
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="计价基本数量">
              <template slot-scope="scope">
                <el-form-item
                  prop="baseUnit"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.baseUnit"
                    clearable
                    disabled
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="批号">
              <template slot-scope="scope">
                <el-form-item
                  prop="batchNum"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.batchNum"
                    clearable
                    disabled
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="计入采购成本">
              <template slot-scope="scope">
                <el-form-item
                  prop="isIncludeProcureCost"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-checkbox
                    @change="inOutChange(1, scope.row, scope.$index)"
                    v-model="scope.row.isIncludeProcureCost"
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="入库单号">
              <template slot-scope="scope">
                <el-form-item
                  prop="inStorageNo"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    :disabled="!scope.row.isIncludeProcureCost"
                    v-model="scope.row.inStorageNo"
                    clearable
                  >
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('inStorageNo', scope.$index)"
                    ></i
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="是否计入合同履约成本">
              <template slot-scope="scope">
                <el-form-item
                  prop="isIncludeContractCost"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-checkbox
                    @change="inOutChange(2, scope.row, scope.$index)"
                    v-model="scope.row.isIncludeContractCost"
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="出库单号">
              <template slot-scope="scope">
                <el-form-item
                  prop="outStorageNo"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.outStorageNo"
                    clearable
                    :disabled="!scope.row.isIncludeContractCost"
                  >
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('outStorageNo', scope.$index)"
                    ></i
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="库存数量">
              <template slot-scope="scope">
                <el-form-item prop="number" label-width="0px" style="margin: 0">
                  <el-input
                    v-model="scope.row.number"
                    clearable
                    disabled
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
          <!-- 标准 -->
          <el-table
            v-if="docType !== 'YFD02_SYS'"
            :data="formData.kingInvoicePayableDetailEntities"
            style="width: 100%"
            highlight-current-row
            border
          >
            <el-table-column label="操作" width="120" fixed>
              <template slot-scope="scope">
                <el-button
                  plain
                  icon="el-icon-minus"
                  size="mini"
                  @click="handleDataDelete(scope.$index, scope.row, 'detail')"
                ></el-button>
              </template>
            </el-table-column>
            <el-table-column
              width="150"
              label="序号"
              type="index"
              align="center"
            ></el-table-column>
            <el-table-column width="150" label="物料编码">
              <template slot-scope="scope">
                <el-form-item
                  prop="materialCode"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.materialCode" clearable readonly>
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('materialCode', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="物料名称">
              <template slot-scope="scope">
                <el-form-item
                  prop="materialName"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.materialName" clearable disabled>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="计价单位">
              <template slot-scope="scope">
                <el-form-item prop="unit" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.unit" clearable readonly>
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('unit', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="含税单价">
              <template slot-scope="scope">
                <el-form-item
                  prop="taxPrice"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.taxPrice" clearable> </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="单价">
              <template slot-scope="scope">
                <el-form-item prop="price" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.price" clearable disabled>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="数量">
              <template slot-scope="scope">
                <el-form-item prop="num" label-width="0px" style="margin: 0">
                  <el-input
                    v-model="scope.row.num"
                    clearable
                    @change="caculateNum(scope.row, scope.$index)"
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="税率%">
              <template slot-scope="scope">
                <el-form-item prop="rate" label-width="0px" style="margin: 0">
                  <el-input
                    v-model="scope.row.rate"
                    clearable
                    @change="caculateNum(scope.row, scope.$index)"
                  >
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('rate', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <!-- <el-table-column width="150" label="直接汇率">
              <template slot-scope="scope">
                <el-form-item
                  prop="directRate"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.directRate"
                    clearable
                    @change="caculateNum(scope.row, scope.$index)"
                  >
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="showDialog('directRate', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="间接汇率">
              <template slot-scope="scope">
                <el-form-item
                  prop="indirectRate"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.indirectRate" clearable disabled>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column> -->
            <el-table-column width="150" label="价税合计">
              <template slot-scope="scope">
                <el-form-item
                  prop="totalTaxPrice"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.totalTaxPrice"
                    clearable
                    @change="
                      caculateNum(scope.row, scope.$index, 'totalTaxPrice')
                    "
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="折扣率%">
              <template slot-scope="scope">
                <el-form-item
                  prop="discountRate"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    @change="discountRateChange(scope.row, scope.$index)"
                    v-model="scope.row.discountRate"
                    clearable
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="税额">
              <template slot-scope="scope">
                <el-form-item
                  prop="rateAmount"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.rateAmount"
                    clearable
                    disabled
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="不含税金额">
              <template slot-scope="scope">
                <el-form-item
                  prop="notTaxAmount"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.notTaxAmount" clearable>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="折扣额">
              <template slot-scope="scope">
                <el-form-item
                  prop="discountAmount"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.discountAmount"
                    clearable
                    disabled
                    @change="
                      caculateNum(scope.row, scope.$index, 'discountAmount')
                    "
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="计价基本数量">
              <template slot-scope="scope">
                <el-form-item
                  prop="baseUnit"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.baseUnit"
                    clearable
                    disabled
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="批号">
              <template slot-scope="scope">
                <el-form-item
                  prop="batchNum"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.batchNum"
                    clearable
                    disabled
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="库存数量">
              <template slot-scope="scope">
                <el-form-item prop="number" label-width="0px" style="margin: 0">
                  <el-input
                    v-model="scope.row.number"
                    clearable
                    disabled
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
        </el-collapse-item>

        <!-- <el-collapse-item title="收款计划" name="plan">
          <el-table
            :data="formData.kingInvoicePayableProcurePlanEntities"
            style="width: 100%"
            highlight-current-row
            border
          >
            <template #empty>
              <el-button plain type="primary" round @click="addNewRow('plan')"
                >添加新行
              </el-button>
            </template>
            <el-table-column label="操作" width="120" fixed>
              <template slot-scope="scope">
                <el-button
                  plain
                  icon="el-icon-plus"
                  size="mini"
                  @click="handleDataAdd(scope.$index, scope.row, 'plan')"
                ></el-button>
                <el-button
                  plain
                  icon="el-icon-minus"
                  size="mini"
                  @click="handleDataDelete(scope.$index, scope.row, 'plan')"
                ></el-button>
              </template>
            </el-table-column>
            <el-table-column
              width="150"
              label="序号"
              type="index"
              align="center"
            ></el-table-column>
            <el-table-column width="150" label="销售开票">
              <template slot-scope="scope">
                <el-form-item
                  prop="invoiceReceivableId"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.invoiceReceivableId" clearable>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="销售订单">
              <template slot-scope="scope">
                <el-form-item
                  prop="saleOrderId"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.saleOrderId" clearable>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="应收金额">
              <template slot-scope="scope">
                <el-form-item
                  prop="receiptAmount"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.receiptAmount" clearable>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="按比例收%">
              <template slot-scope="scope">
                <el-form-item
                  prop="receiptRatio"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.receiptRatio" clearable>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="到期日">
              <template slot-scope="scope">
                <el-form-item
                  prop="createTime"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-date-picker
                    v-model="scope.row.createTime"
                    type="date"
                    placeholder="选择日期"
                  >
                  </el-date-picker>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column width="150" label="备注">
              <template slot-scope="scope">
                <el-form-item
                  prop="remarks"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.remarks" clearable> </el-input>
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
        </el-collapse-item> -->
        <!-- <el-collapse-item title="销售订单" name="order">
                    <el-table
                        :data="formData.orderEntities"
                        style="width: 100%"
                        highlight-current-row
                        border
                    >
                        <template #empty>
                            <el-button
                                plain
                                type="primary"
                                round
                                @click="addNewRow('order')"
                                >添加新行
                            </el-button>
                        </template>
                        <el-table-column width="150" label="操作" width="120" fixed>
                            <template slot-scope="scope">
                                <el-button
                                    plain
                                    icon="el-icon-plus"
                                    size="mini"
                                    @click="
                                        handleDataAdd(
                                            scope.$index,
                                            scope.row,
                                            'order'
                                        )
                                    "
                                ></el-button>
                                <el-button
                                    plain
                                    icon="el-icon-minus"
                                    size="mini"
                                    @click="
                                        handleDataDelete(
                                            scope.$index,
                                            scope.row,
                                            'order'
                                        )
                                    "
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column width="150"
                            label="序号"
                            type="index"
                            align="center"
                        ></el-table-column>
                        <el-table-column width="150" label="业务类型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop=""
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.businessType"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="变更原因">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="changeReason"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.changeReason"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="币别">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="currency"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.currency"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="客户">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="customerId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.customerId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="客户名称">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="customerName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input v-model="scope.row.customerName">
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="交货地点">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="deliveryAddress"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.deliveryAddress"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="交货方式">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="deliveryMethod"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.deliveryMethod"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="所属公司">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="deptId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.deptId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="折扣表">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="discountInfoId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.discountInfoId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="流程实例">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="instanceId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.instanceId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="是否含税">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="isTax"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-select
                                        v-model="scope.row.isTax"
                                        placeholder="请选择"
                                        style="width: 100%"
                                    >
                                        <el-option label="否" value="0">
                                        </el-option>
                                        <el-option label="是" value="1">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="单据编码">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="kingDocCode"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.kingDocCode"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="单据类型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="kingDocTypeId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.kingDocTypeId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="层级">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="level"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.level"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="保证金">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="margin"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.margin"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="保证金比例">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="marginLevel"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.marginLevel"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="流程模型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="modelId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.modelId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="源订单编号">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="originalOrderCode"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.originalOrderCode"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="付款方">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="payer"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.payer"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="收款条件">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="paymentTerms"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.paymentTerms"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="是否价格税">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="priceTax"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-select
                                        v-model="scope.row.priceTax"
                                        placeholder="请选择"
                                        style="width: 100%"
                                    >
                                        <el-option label="否" value="0">
                                        </el-option>
                                        <el-option label="是" value="1">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="价目表">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="priceinfoId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.priceinfoId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="汇款">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="rate"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.rate"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="汇率类型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="rateType"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.rateType"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="收货方">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="receivingParty"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.receivingParty"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="订单编号">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="saleCode"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.saleCode"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="日期">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="saleDate"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.saleDate"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="销售部门">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="saleDept"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.saleDept"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="销售组">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="saleGroup"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.saleGroup"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="销售员">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="saleId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.saleId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="结算方">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="settlementParty"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.settlementParty"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="结算方式">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="settlementType"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.settlementType"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="收货地址">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="shippingAddress"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.shippingAddress"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="收货联系人">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="shippingPerson"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.shippingPerson"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="收货人姓名">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="shippingPersonName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.shippingPersonName"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="联系人方式">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="shippingPhone"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.shippingPhone"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="源单类型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="sourceDocType"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-select
                                        v-model="scope.row.sourceDocType"
                                        placeholder="请选择"
                                        style="width: 100%"
                                    >
                                        <el-option label="销售合同" value="0">
                                        </el-option>
                                        <el-option label="销售报价单" value="1">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="单据类型名称">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="sourceDocTypeName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.sourceDocTypeName"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="审核状态">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="state"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.state"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="税额">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="taxAmount"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.taxAmount"
                                        clearable
                                        disabled
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="变更状态">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="updateState"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-select
                                        v-model="scope.row.updateState"
                                        placeholder="请选择"
                                        style="width: 100%"
                                    >
                                        <el-option label="未变更" value="0">
                                        </el-option>
                                        <el-option label="已变更" value="1">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="金额">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="valueTax"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.valueTax"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-collapse-item> -->
        <!-- <el-collapse-item title="出入库单记录" name="storage">
                    <el-table
                        :data="formData.kingInventoryEntities"
                        style="width: 100%"
                        highlight-current-row
                        border
                    >
                        <template #empty>
                            <el-button
                                plain
                                type="primary"
                                round
                                @click="addNewRow('storage')"
                                >添加新行
                            </el-button>
                        </template>
                        <el-table-column width="150" label="操作" width="120" fixed>
                            <template slot-scope="scope">
                                <el-button
                                    plain
                                    icon="el-icon-plus"
                                    size="mini"
                                    @click="
                                        handleDataAdd(
                                            scope.$index,
                                            scope.row,
                                            'storage'
                                        )
                                    "
                                ></el-button>
                                <el-button
                                    plain
                                    icon="el-icon-minus"
                                    size="mini"
                                    @click="
                                        handleDataDelete(
                                            scope.$index,
                                            scope.row,
                                            'storage'
                                        )
                                    "
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column width="150"
                            label="序号"
                            type="index"
                            align="center"
                        ></el-table-column>
                        <el-table-column width="150" label="入库批次号">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="batchNumber"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.batchNumber"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="合同">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="contractId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.contractId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="入库类型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="inStorageType"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-select
                                        v-model="scope.row.inStorageType"
                                        placeholder="请选择"
                                        clearable
                                        :style="{ width: '100%' }"
                                    >
                                        <el-option
                                            label="甲供入库 "
                                            value="1"
                                        ></el-option>
                                        <el-option
                                            label="自购入库 "
                                            value="2"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="出入库日期">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="inOutTime"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-date-picker
                                        v-model="scope.row.inOutTime"
                                        type="date"
                                        placeholder="选择日期"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="订单">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="orderId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.orderId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="项目">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="projectId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.projectId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="出入库单号">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="purchaseCode"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.purchaseCode"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="流程状态">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="state"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.state"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="供应商">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="supplierId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.supplierId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="出入库类型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="type"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-select
                                        v-model="scope.row.type"
                                        placeholder="请选择"
                                        clearable
                                        :style="{ width: '100%' }"
                                    >
                                        <el-option
                                            label="入库 "
                                            value="1"
                                        ></el-option>
                                        <el-option
                                            label="出库 "
                                            value="2"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="领用人">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="useUserId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.useUserId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="仓库">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="warehouseId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.warehouseId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="仓库区域">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="warehouseRegionId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.warehouseRegionId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="备注">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="remarks"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.remarks"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-collapse-item> -->
        <!-- <el-collapse-item title="退料单" name="refund">
                    <el-table
                        :data="formData.kingInventoryEntities"
                        style="width: 100%"
                        highlight-current-row
                        border
                    >
                        <template #empty>
                            <el-button
                                plain
                                type="primary"
                                round
                                @click="addNewRow('storage')"
                                >添加新行
                            </el-button>
                        </template>
                        <el-table-column width="150" label="操作" width="120" fixed>
                            <template slot-scope="scope">
                                <el-button
                                    plain
                                    icon="el-icon-plus"
                                    size="mini"
                                    @click="
                                        handleDataAdd(
                                            scope.$index,
                                            scope.row,
                                            'storage'
                                        )
                                    "
                                ></el-button>
                                <el-button
                                    plain
                                    icon="el-icon-minus"
                                    size="mini"
                                    @click="
                                        handleDataDelete(
                                            scope.$index,
                                            scope.row,
                                            'storage'
                                        )
                                    "
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column width="150"
                            label="序号"
                            type="index"
                            align="center"
                        ></el-table-column>
                        <el-table-column width="150" label="结算方编码">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="balanceCode"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.balanceCode"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="结算方名称">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="balanceId"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.balanceId"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="本位币">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="baseCurrency"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.baseCurrency"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="货主客户">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="cargoCustomer"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.cargoCustomer"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="货主">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="cargoOwner"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.cargoOwner"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="货主类型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="cargoOwnerType"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.cargoOwnerType"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="验收方式">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="checkMethod"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.checkMethod"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="确认人">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="confirmName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.confirmName"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="确认状态">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="confirmState"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.confirmState"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="确认日期">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="confirmTime"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-date-picker
                                        clearable
                                        v-model="scope.row.confirmTime"
                                        type="date"
                                        placeholder="选择日期"
                                        format="yyyy-MM-dd"
                                        value-format="yyyy-MM-dd"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="创建人">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="createName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.createName"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="折扣表">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="discountInfoCode"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.discountInfoCode"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="业务类型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="docBusinessType"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.docBusinessType"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="退料单编码">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="docCode"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.docCode"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="单据状态">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="docStatus"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.docStatus"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="邮箱">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="email"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.email"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="审核人">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="examineName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.examineName"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="审核日期">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="examineTime"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-date-picker
                                        v-model="scope.row.examineTime"
                                        clearable
                                        type="date"
                                        placeholder="选择日期"
                                        format="yyyy-MM-dd"
                                        value-format="yyyy-MM-dd"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="汇率">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="exchangeRate"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.exchangeRate"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="汇率类型">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="exchangeRateType"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.exchangeRateType"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column width="150" label="库存组">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="inventoryGroup"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.inventoryGroup"
                                        clearable
                                    >
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        
                    </el-table>
                </el-collapse-item> -->
      </el-collapse>
    </el-form>
    <el-dialog
      v-if="open"
      :title="dialogTitle"
      :visible.sync="open"
      width="50%"
      append-to-body
      destroy-on-close
    >
      <components :is="currentCom" @getSelectVal="getSelectVal" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancelSelect">取 消</el-button>
        <el-button type="primary" @click="confirmSelect">确 定</el-button>
      </span>
    </el-dialog>
    <!-- <el-dialog
      title="更改单据类型"
      :visible.sync="docTypeShow"
      width="30%"
      append-to-body
      destroy-on-close
    >
      <span>单据类型已改变，系统将创建新单，是否继续？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="docTypeShow = false">取 消</el-button>
        <el-button type="primary" @click="changeDocType">确 定</el-button>
      </span>
    </el-dialog> -->
  </div>
</template>
<script>
import { getDocTypeList } from "@/api/system/purchase";
import { addInfo, addInfoTemporary } from "@/api/finance/procureInvoice";
import { getCompute } from "@/api/finance/info";
import Customer from "./dialog/customer.vue";
import Currency from "./dialog/currencys.vue";
import Receipt from "./dialog/receipt.vue";
import Dept from "./dialog/dept.vue";
import SaleUser from "./dialog/saleUser.vue";
import Material from "./dialog/materials.vue";
import TaxRate from "./dialog/taxRates.vue";
import Unit from "./dialog/units.vue";
import Fee from "./dialog/fee.vue";
import FeeDept from "./dialog/feeDept.vue";
import Supplier from "./dialog/supplier.vue";
import PayTerms from "./dialog/payTerms.vue";
import DirectRate from "./dialog/directRate.vue";
import payOrder from "./dialog/payOrder.vue";
import backOrder from "./dialog/backOrder.vue";
import inOrder from "./dialog/inOrder.vue";
import spilloverOrder from "./dialog/spilloverOrder.vue";
import inStorageNo from "./dialog/inStorageNo.vue";
import outStorageNo from "./dialog/outStorageNo.vue";

export default {
  props: ["rowId"],
  components: {
    outStorageNo,
    inStorageNo,
    payOrder,
    backOrder,
    inOrder,
    spilloverOrder,
    Customer,
    Currency,
    Receipt,
    Dept,
    SaleUser,
    Material,
    TaxRate,
    Unit,
    Fee,
    FeeDept,
    Supplier,
    PayTerms,
    DirectRate,
  },
  data() {
    return {
      activeName: ["basic", "detail", "plan", "order", "storage", "refund"],
      dialogTitle: "",
      open: false,
      selectItem: [],
      docTypeStandard: "",
      docTypeExpanse: "",
      currentCom: "",
      documentTypeList: [],
      sourceDocType: "",
      docType: "",
      level: "",
      docTypeShow: false,
      formData: {
        // kingInventoryEntities: [],
        kingInvoicePayableDetailEntities: [],
        kingInvoicePayableEntity: {
          accountType: "2",
          bizTime: "",
          businessType: "13",
          createBy: "",
          createTime: "",
          currencyCode: "",
          currencyId: "",
          currencyName: "",
          deptId: "",
          discountAmount: "",
          docNo: "",
          docTypeCode: "",
          dueCalculationTime: "",
          dueTime: "",
          forderCode: "",
          goodsCode: "",
          goodsSupplierId: "",
          id: "",
          instanceId: "",
          isExtraPriceTax: "",
          isFee: "",
          isIncludeTaxPrice: "",
          isSend: 0,
          isTaxCostAmount: "",
          isTicketsBefore: "",
          modelId: this.$store.state.workflow.businessConfig.id,
          orderSupplierId: "",
          pageNo: 0,
          pageSize: 0,
          params: {},
          parentId: "",
          payDeptId: "",
          payDeptName: "",
          payTermsId: "",
          payTermsTitle: "",
          procureCompany: "",
          procureCompanyId: "",
          procureDeptCode: "",
          procureDeptId: "",
          procureDeptName: "",
          procureUser: "",
          procureUserId: "",
          receiptCode: "",
          receiptSupplierId: "",
          remark: "",
          remarks: "",
          searchValue: "",
          settlementCode: "",
          settlementDept: "",
          settlementDeptId: "",
          settlementTypeId: "",
          sourceDocType: this.sourceDocType,
          state: "",
          status: "",
          supplierCode: "",
          supplierId: "",
          supplierName: "",
          totalTaxPrice: "",
          updateBy: "",
          updateTime: "",
        },
        kingInvoicePayableProcurePlanEntities: [],
        // orderEntities: [],
        // kingProcureRefundEntities: [],
      },
      rules: {
        kingInvoicePayableEntity: {
          docTypeCode: [
            {
              required: true,
              message: "请选择单据类型",
              trigger: "change",
            },
          ],
          supplierName: [
            {
              required: true,
              message: "请选择供应商",
              trigger: "change",
            },
          ],
          currencyName: [
            {
              required: true,
              message: "请选择币别",
              trigger: "change",
            },
          ],
          settlementDept: [
            {
              required: true,
              message: "请输入结算组织",
              trigger: "change",
            },
          ],
          bizTime: [
            {
              required: true,
              message: "请选择业务时间",
              trigger: "change",
            },
          ],
          payDeptName: [
            {
              required: true,
              message: "请输入付款组织",
              trigger: "change",
            },
          ],
          dueTime: [
            {
              required: true,
              message: "请选择到期日",
              trigger: "change",
            },
          ],
        },
      },
      accountTypeOptions: [
        {
          label: "暂估应付",
          value: "2",
        },
        {
          label: "财务应付",
          value: "3",
        },
      ],
      docTypeIdOptions: [],
      isExtraPriceTaxOptions: [
        {
          label: "是",
          value: "1",
        },
        {
          label: "否",
          value: "2",
        },
      ],
      isFeeOptions: [
        {
          label: "是",
          value: "1",
        },
        {
          label: "否",
          value: "2",
        },
      ],
      isIncludeTaxPriceOptions: [
        {
          label: "是",
          value: "1",
        },
        {
          label: "否",
          value: "2",
        },
      ],
      docTypeIdProps: {
        multiple: false,
      },
      isTaxCostAmountOptions: [
        {
          label: "是",
          value: "1",
        },
        {
          label: "否",
          value: "2",
        },
      ],
      isTicketsBeforeOptions: [
        {
          label: "是",
          value: "1",
        },
        {
          label: "否",
          value: "2",
        },
      ],
      props: {},
      dialogType: "",
    };
  },
  methods: {
    handleChange() {},
    // 新增新行
    addNewRow(type) {
      const nameMap = {
        detail: () => {
          let obj = {
            baseUnit: "",
            batchNum: "",
            bearDeptCode: "",
            bearDeptName: "",
            createBy: "",
            createTime: "",
            deptId: "",
            discountAmount: "",
            discountRate: "",
            feeCode: "",
            feeName: "",
            id: "",
            inStorageNo: "",
            invoicePayableId: "",
            isGift: 0,
            isIncludeContractCost: 0,
            isIncludeProcureCost: 0,
            materialCode: "",
            materialId: "",
            materialName: "",
            notTaxAmount: "",
            notTaxAmountCurrency: "",
            num: "",
            orderId: "",
            outStorageNo: "",
            pageNo: 0,
            pageSize: 0,
            price: "",
            params: {},
            payableTaxPrice: "",
            rate: "",
            rateAmount: "",
            rateAmountCurrency: "",
            remark: "",
            searchValue: "",
            sourceDocType: this.sourceDocType,
            sourceId: "",
            sourceMaterialDetailId: "",
            taxPrice: "",
            totalTaxPrice: "",
            totalTaxPriceCurrency: "",
            unit: "",
            updateBy: "",
            updateTime: "",
            directRate: "",
            indirectRate: "",
            taxAmount: "",
          };
          this.formData.kingInvoicePayableDetailEntities.push(obj);
        },
        plan: () => {
          let obj = {
            createBy: "",
            createTime: "",
            dueTime: "",
            feeId: "",
            id: "",
            invoicePayableId: "",
            materialId: "",
            ownCurrencyId: "",
            pageNo: 0,
            pageSize: 0,
            params: {},
            payAmount: "",
            payRatio: "",
            procureOrderId: "",
            remark: "",
            remarks: "",
            searchValue: "",
            updateBy: "",
            updateTime: "",
          };
          this.formData.kingInvoicePayableProcurePlanEntities.push(obj);
        },
        order: () => {
          let obj = {
            applyFormUnpaidAmount: "",
            applyId: "",
            applyTime: "",
            baseCurrency: "",
            businessType: "",
            changeReason: "",
            changeTime: "",
            checkMethod: "",
            closeName: "",
            closeReason: "",
            closeState: "",
            closeTime: "",
            confirmName: "",
            confirmState: "",
            confirmTime: "",
            createId: "",
            createName: "",
            createTime: "",
            discountInfoId: "",
            docBusinessType: "",
            docType: "",
            documentCode: "",
            ensure: "",
            ensureRate: "",
            examineName: "",
            examineTime: "",
            exchangeRate: "",
            exchangeRateType: "",
            focusSettlementDept: "",
            id: "",
            instanceId: "",
            invalidName: "",
            invalidState: "",
            invalidTime: "",
            isExtraPriceTax: true,
            isManualClose: true,
            isSend: 0,
            isTax: true,
            isTemp: true,

            lastUpdateName: "",
            lastUpdateTime: "",
            level: 0,
            limit: 0,
            modelId: "",
            money: "",
            moneyAmount: "",
            moneyAmountBase: "",
            orderDetails: [],
            orderNumber: "",
            orderPaymentExecutions: [],
            orderPaymentPlans: [],
            orderPurchaseTerms: [],
            orderSupplier: {
              balanceId: "",
              changeTime: "",
              createTime: "",
              email: "",
              id: "",

              orderId: "",
              phone: "",
              post: "",
              providerAddress: "",
              providerContacts: "",
              providerId: "",
              receiveId: "",
              userId: "",
            },
            originalOrderCode: "",
            page: 0,
            parentId: "",
            priceInfoId: "",
            pricingTimePoint: "",
            projectId: "",
            projectName: "",
            purchaseDept: "",
            purchaseGroup: "",
            purchaseOrg: "",
            settlementCurrency: "",
            settlementMethod: "",
            sourceDocType: this.sourceDocType,
            state: "",
            status: 0,
            supplierId: "",
            supplierName: "",
            taxAmount: "",
            taxAmountBase: "",
            termOfPayment: "",
            token: "",
            totalPaymentAmount: "",
            totalPaymentApplyAmount: "",
            totalPriceTax: "",
            totalPriceTaxBase: "",
            totalReturnAmount: "",
            totalUnpaidAmount: "",
            updateName: "",
            updateState: "",
            updateTime: "",
            userId: "",
            version: "",
            wholeDiscountAmount: "",
          };
          this.formData.orderEntities.push(obj);
        },
        storage: () => {
          let obj = {
            balanceCode: "",
            balanceId: "",
            baseCurrency: "",
            cargoOwner: "",
            cargoOwnerType: "",
            childTye: "",
            confirmName: "",
            confirmState: "",
            confirmTime: "",
            createName: "",
            createTime: "",
            discountInfoCode: "",
            docBusinessType: "",
            docCode: "",
            docStatus: "",
            docType: "",
            email: "",
            examineName: "",
            examineTime: "",
            exchangeRate: "",
            exchangeRateType: "",
            id: "",
            invalidName: "",
            invalidState: "",
            invalidTime: "",
            inventoryGroup: "",
            inventoryTime: "",
            isExtraPriceTax: true,
            isTax: true,

            lastUpdateName: "",
            lastUpdateTime: "",
            managementBy: "",
            materialLists: [
              {
                batchNum: "",
                changeTime: "",
                createTime: "",
                currentReconciliationCode: "",
                defectiveDiscountAmount: "",
                historyReconciliationCode: "",
                id: "",
                inventoryId: "",
                inventoryStatus: "",
                inventoryType: "",
                inventoryUnit: "",
                isGiveaway: true,
                isReconciliation: true,

                materialCode: "",
                materialDesc: "",
                materialDetail: {
                  amountMoney: "",
                  amountMoneyBase: "",
                  auxiliaryUnit: "",
                  batchNum: "",
                  bomVer: "",
                  businessProcess: "",
                  changeTime: "",
                  containsTaxPrice: "",
                  createTime: "",
                  discountAmount: "",
                  discountRate: "",
                  entryPriceList: "",
                  id: "",
                  inventoryId: "",
                  inventoryMaterialId: "",

                  manufactureTime: "",
                  materialCode: "",
                  materialDetailSerials: [
                    {
                      changeTime: "",
                      createTime: "",
                      id: "",
                      inventoryId: "",
                      inventoryMaterialId: "",

                      materialDetailId: "",
                      remark: "",
                      serialCode: "",
                      userId: "",
                    },
                  ],
                  materialId: "",
                  materialModel: "",
                  materialName: "",
                  netAmount: "",
                  orderCode: "",
                  payableCloseStatus: "",
                  payableCloseTime: "",
                  planTrackingCode: "",
                  price: "",
                  priceCap: "",
                  priceCoefficient: "",
                  priceDiscount: "",
                  priceFloor: "",
                  pricingNum: "",
                  pricingUnit: "",
                  receivedNum: "",
                  remark: "",
                  requireTrackingCode: "",
                  returnRelatedNum: "",
                  sampleDestructionNum: "",
                  serialCodeUnit: "",
                  serialCodeUnitNum: "",
                  serialCodeUpload: "",
                  shelfLifeCycle: "",
                  sourceDocCode: "",
                  sourceDocType: this.sourceDocType,
                  supplierBatchNum: "",
                  taxAmount: "",
                  taxAmountBase: "",
                  taxRate: "",
                  totalTaxPrice: "",
                  totalTaxPriceBase: "",
                  userId: "",
                  validTo: "",
                  warrantyTime: "",
                  warrantyUnit: "",
                },
                materialId: "",
                materialModel: "",
                materialName: "",
                moneyAmount: "",
                netPrice: "",
                pricingNum: "",
                pricingUnit: "",
                purchaseNum: 0,
                purchaseUnit: "",
                receiptsNum: 0,
                receivableNum: 0,
                relationId: "",
                remark: "",
                userId: "",
                warehouseCode: "",
                warehouseId: "",
                warehousePosition: "",
              },
            ],
            moneyAmount: "",
            priceInfoCode: "",
            pricingTimePoint: "",
            providerAddress: "",
            providerCode: "",
            providerContacts: "",
            providerId: "",
            purchaseBy: "",
            purchaseDept: "",
            purchaseGroup: "",
            purchaseOrg: "",
            receiveCode: "",
            receiveId: "",
            receivingDept: "",
            receivingOrg: "",
            requireDept: "",
            settlementCurrency: "",
            settlementMethod: "",
            settlementOrg: "",
            supplierCode: "",
            supplierId: "",
            taxAmount: "",
            termOfPayment: "",
            totalPriceTax: "",
            type: "",
            userId: "",
          };
          this.formData.kingInventoryEntities.push(obj);
        },
        refund: () => {
          let obj = {
            balanceCode: "",
            balanceId: "",
            baseCurrency: "",
            cargoCustomer: "",
            cargoOwner: "",
            cargoOwnerType: "",
            checkMethod: "",
            confirmName: "",
            confirmState: "",
            confirmTime: "",
            createName: "",
            createTime: "",
            discountInfoCode: "",
            docBusinessType: "",
            docCode: "",
            docStatus: "",
            docType: "",
            email: "",
            examineName: "",
            examineTime: "",
            exchangeRate: "",
            exchangeRateType: "",
            id: "",
            inventoryGroup: "",
            isExtraPriceTax: "",
            isTax: "",

            lastUpdateName: "",
            lastUpdateTime: "",
            managementBy: "",
            materialLists: [
              {
                amountMoney: "",
                amountMoneyBase: "",
                auxiliaryUnit: "",
                auxiliaryUnitNum: "",
                baseUnit: "",
                baseUnitPrice: "",
                batchNum: "",
                cargoOwner: "",
                cargoOwnerType: "",
                containsTaxPrice: "",
                costPrice: "",
                costPriceBase: "",
                createBy: "",
                createTime: "",
                deductionNum: "",
                discountAmount: "",
                discountRate: "",
                fixedPricingUnit: "",
                id: "",
                inventoryNumBase: "",
                inventoryStatus: "",
                inventoryUnit: "",
                invoicingCompletedStatus: "",
                isGiveaway: "",

                keepingBy: "",
                materialCode: "",
                materialDetail: {
                  amountMoney: "",
                  amountMoneyBase: "",
                  auxiliaryUnit: "",
                  batchNum: "",
                  bomVer: "",
                  businessProcess: "",
                  containsTaxPrice: "",
                  createBy: "",
                  createTime: "",
                  discountAmount: "",
                  discountRate: "",
                  entryPriceList: "",
                  feeInfoCode: "",
                  id: "",
                  invoicedNum: "",
                  invoicingCompletedStatus: "",

                  manufactureTime: "",
                  materialCode: "",
                  materialDetailSerials: [
                    {
                      createBy: "",
                      createTime: "",
                      id: "",

                      materialDetailId: "",
                      procureRefundId: "",
                      procureRefundMaterialId: "",
                      remark: "",
                      serialCode: "",
                      updateBy: "",
                      updateTime: "",
                    },
                  ],
                  materialId: "",
                  materialModel: "",
                  materialName: "",
                  netAmount: "",
                  orderCode: "",
                  payableCloseStatus: "",
                  payableCloseTime: "",
                  planTrackingCode: "",
                  price: "",
                  priceCap: "",
                  priceCoefficient: "",
                  priceDiscount: "",
                  priceFloor: "",
                  pricingNum: "",
                  pricingUnit: "",
                  procureRefundId: "",
                  procureRefundMaterialId: "",
                  refundNum: "",
                  requireTrackingCode: "",
                  serialCodeUnit: "",
                  serialCodeUnitNum: "",
                  serialCodeUpload: "",
                  shelfLifeCycle: "",
                  sourceDocCode: "",
                  sourceDocType: this.sourceDocType,
                  supplierBatchNum: "",
                  systemPricing: "",
                  taxAmount: "",
                  taxAmountBase: "",
                  taxRate: "",
                  totalTaxPrice: "",
                  totalTaxPriceBase: "",
                  updateBy: "",
                  updateTime: "",
                  validTo: "",
                  warrantyTime: "",
                  warrantyUnit: "",
                },
                materialId: "",
                materialModel: "",
                materialName: "",
                netAmount: "",
                price: "",
                priceDiscount: "",
                pricingNum: "",
                pricingNumBase: "",
                pricingUnit: "",
                projectCode: "",
                projectId: "",
                purchaseNum: "",
                purchaseNumBase: "",
                purchaseUnit: "",
                refundNum: "",
                refundNumAuxiliary: "",
                refundedNum: "",
                relationId: "",
                remark: "",
                repairNum: "",
                sourceInventoryCode: "",
                sourceInventoryId: "",
                sourceOrderCode: "",
                sourceOrderId: "",
                sourceType: "",
                supplierBatchNum: "",
                supplierMaterialCode: "",
                supplierMaterialName: "",
                taxAmount: "",
                taxAmountBase: "",
                taxRate: "",
                totalCost: "",
                totalCostBase: "",
                totalTaxPrice: "",
                totalTaxPriceBase: "",
                type: 0,
                updateBy: "",
                updateTime: "",
                warehouseCode: "",
                warehouseId: "",
                warehousePosition: "",
              },
            ],
            moneyAmount: "",
            moneyAmountBase: "",
            priceInfoCode: "",
            pricingTimePoint: "",
            providerAddress: "",
            providerCode: "",
            providerContacts: "",
            providerId: "",
            purchaseBy: "",
            purchaseDept: "",
            purchaseGroup: "",
            purchaseOrg: "",
            receiveCode: "",
            receiveId: "",
            refundDept: "",
            refundMethod: "",
            refundOrg: "",
            refundReason: "",
            refundTime: "",
            refundType: "",
            requireOrg: "",
            settlementCurrency: "",
            settlementMethod: "",
            settlementOrg: "",
            supplementMethod: "",
            supplierCode: "",
            supplierId: "",
            taxAmount: "",
            taxAmountBase: "",
            termOfPayment: "",
            totalCost: "",
            totalCostBase: "",
            totalPriceTax: "",
            totalPriceTaxBase: "",
            type: 0,
            updateBy: "",
            updateTime: "",
          };
          this.formData.kingProcureRefundEntities.push(obj);
        },
      };
      nameMap[type] ? nameMap[type]() : "";
    },
    // 新增列表行
    handleDataAdd(index, row, type) {
      this.addNewRow(type);
    },
    // 删除列表行
    handleDataDelete(index, row, type) {
      this.$confirm("此操作将删除该记录, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          const nameMap = {
            detail: () => {
              this.formData.kingInvoicePayableDetailEntities.splice(index, 1);
            },
            plan: () => {
              this.formData.kingInvoicePayableProcurePlanEntities.splice(
                index,
                1
              );
            },
            order: () => {
              this.formData.orderEntities.splice(index, 1);
            },
            storage: () => {
              this.formData.kingInventoryEntities.splice(index, 1);
            },
            refund: () => {
              this.formData.kingProcureRefundEntities.splice(index, 1);
            },
          };
          nameMap[type] ? nameMap[type]() : "";
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    // 打开弹窗
    showDialog(type, index) {
      this.open = true;
      this.dialogType = type;
      this.selectItem = [];
      this.currentIndex = index;
      const nameMap = {
        supplier: () => {
          this.currentCom = Supplier;
          this.dialogTitle = "选择供应商";
        },
        payTerms: () => {
          this.currentCom = PayTerms;
          this.dialogTitle = "选择付款条件";
        },
        customer: () => {
          this.currentCom = Customer;
          this.dialogTitle = "选择客户";
        },
        currency: () => {
          this.currentCom = Currency;
          this.dialogTitle = "选择币别";
        },

        dept: () => {
          this.currentCom = Dept;
          this.dialogTitle = "选择采购部门";
          this.level = 2;
        },
        user: () => {
          this.currentCom = SaleUser;
          this.dialogTitle = "选择采购员";
        },
        materialCode: () => {
          this.dialogTitle = "选择物料";
          this.currentCom = Material;
        },
        rate: () => {
          this.dialogTitle = "选择税率";
          this.currentCom = TaxRate;
        },
        unit: () => {
          this.dialogTitle = "选择计价单位";
          this.currentCom = Unit;
        },
        fee: () => {
          this.dialogTitle = "选择费用项目";
          this.currentCom = Fee;
        },
        feeDept: () => {
          this.dialogTitle = "选择部门";
          this.currentCom = FeeDept;
        },
        directRate: () => {
          this.dialogTitle = "选择汇率";
          this.currentCom = DirectRate;
        },
        payOrder: () => {
          this.dialogTitle = "选择采购订单";
          this.currentCom = payOrder;
        },
        inOrder: () => {
          this.dialogTitle = "选择采购入库单";
          this.currentCom = inOrder;
        },
        backOrder: () => {
          this.dialogTitle = "选择采购退料单";
          this.currentCom = backOrder;
        },
        spilloverOrder: () => {
          this.dialogTitle = "选择冲红应付单";
          this.currentCom = spilloverOrder;
        },
        outStorageNo: () => {
          this.dialogTitle = "选择出库单号";
          this.currentCom = outStorageNo;
        },
        inStorageNo: () => {
          this.dialogTitle = "选择入库单号";
          this.currentCom = inStorageNo;
        },
        bearDeptName: () => {
          this.dialogTitle = "选择费用承担部门";
          this.currentCom = Dept;
        },
        procureCompany: () => {
          this.dialogTitle = "选择费采购组织";
          this.currentCom = Dept;
        },
        settlementDeptId: () => {
          this.dialogTitle = "选择结算组织";
          this.currentCom = Dept;
        },
        payDeptId: () => {
          this.dialogTitle = "选择付款组织";
          this.currentCom = Dept;
        },
      };
      nameMap[type] ? nameMap[type]() : "";
    },
    // 弹窗关闭事件
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
          this.selectItem = [];
        })
        .catch((_) => {});
    },
    // 弹窗取消按钮
    cancelSelect() {
      this.open = false;
      this.selectItem = [];
    },
    // 弹窗选择
    getSelectVal(val) {
      this.selectItem = val;
    },
    // 弹窗确认
    confirmSelect() {
      const nameMap = {
        supplier: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.supplierId =
            this.selectItem[0].id;
          this.formData.kingInvoicePayableEntity.supplierCode =
            this.selectItem[0].supplierCode;
          this.formData.kingInvoicePayableEntity.supplierName =
            this.selectItem[0].supplierName;
          this.open = false;
        },
        payTerms: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.payTermsId =
            this.selectItem[0].id;
          this.formData.kingInvoicePayableEntity.payTermsTitle =
            this.selectItem[0].title;
          this.open = false;
        },
        customer: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.customerName =
            this.selectItem[0].customerName;
          this.formData.kingInvoicePayableEntity.customerId =
            this.selectItem[0].id;
          this.open = false;
        },
        currency: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.currencyName =
            this.selectItem[0].currencyName;
          this.formData.kingInvoicePayableEntity.currencyId =
            this.selectItem[0].id;
          this.formData.kingInvoicePayableEntity.currencyCode =
            this.selectItem[0].currencyCode;
          this.formData.kingInvoicePayableEntity.rate = this.selectItem[0].rate;
          this.changeRate(this.selectItem[0].rate);
          this.open = false;
        },
        receipt: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.receiptConditionId =
            this.selectItem[0].id;
          this.open = false;
        },
        dept: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.procureDeptId =
            this.selectItem[0].deptId;
          this.formData.kingInvoicePayableEntity.procureDeptCode =
            this.selectItem[0].deptCode;
          this.formData.kingInvoicePayableEntity.procureDeptName =
            this.selectItem[0].deptName;
          this.open = false;
        },
        procureCompany: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.procureCompanyId =
            this.selectItem[0].deptId;
          this.formData.kingInvoicePayableEntity.procureCompany =
            this.selectItem[0].deptName;
          this.open = false;
        },
        settlementDeptId: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.settlementDeptId =
            this.selectItem[0].deptId;
          this.formData.kingInvoicePayableEntity.settlementDept =
            this.selectItem[0].deptName;
          this.open = false;
        },
        payDeptId: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.payDeptId =
            this.selectItem[0].deptId;
          this.formData.kingInvoicePayableEntity.payDeptName =
            this.selectItem[0].deptName;
          this.open = false;
        },
        user: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.formData.kingInvoicePayableEntity.procureUserId =
            this.selectItem[0].userId;
          this.formData.kingInvoicePayableEntity.procureUser =
            this.selectItem[0].userName;
          this.open = false;
        },
        materialCode: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }

          this.handleListBack(
            this.formData.kingInvoicePayableDetailEntities,
            "detail",
            true
          );
          this.open = false;
        },
        unit: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.$set(
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex],
            "unit",
            this.selectItem[0].meteringUnitCode
          );
          this.open = false;
        },
        rate: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.$set(
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex],
            "rate",
            this.selectItem[0].rate
          );
          this.open = false;
          this.caculateNum(
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex],
            this.currentIndex
          );
        },
        fee: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.$set(
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex],
            "feeId",
            this.selectItem[0].id
          );
          this.$set(
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex],
            "feeCode",
            this.selectItem[0].feeCode
          );
          this.open = false;
        },
        feeDept: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.$set(
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex],
            "feeBearDeptId",
            this.selectItem[0].deptId
          );
          this.open = false;
        },
        directRate: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }

          this.formData.kingInvoicePayableDetailEntities[
            this.currentIndex
          ].directRate = this.selectItem[0].directRate;
          this.formData.kingInvoicePayableDetailEntities[
            this.currentIndex
          ].indirectRate = this.selectItem[0].indirectRate;
          this.open = false;
          this.caculateNum(
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex],
            this.currentIndex
          );
        },
        payOrder: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.selectItem.forEach((e) => {
            this.addOrderDetails(e);
          });
          this.open = false;
        },
        inOrder: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.selectItem.forEach((e) => {
            this.addOrderDetails(e);
          });
          this.open = false;
        },
        backOrder: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.selectItem.forEach((e) => {
            this.addOrderDetails(e);
          });
          this.open = false;
        },
        spilloverOrder: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          this.selectItem.forEach((e) => {
            this.addOrderDetails(e);
          });
          this.open = false;
        },
        inStorageNo: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          let row =
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex];
          row.inStorageNo = this.selectItem[0].inStorageNo;
          this.$set(
            this.formData.kingInvoicePayableDetailEntities,
            this.currentIndex,
            row
          );
          this.open = false;
        },
        outStorageNo: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          let row =
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex];
          row.outStorageNo = this.selectItem[0].outStorageNo;
          this.$set(
            this.formData.kingInvoicePayableDetailEntities,
            this.currentIndex,
            row
          );
          this.open = false;
        },
        bearDeptName: () => {
          if (this.selectItem.length !== 1) {
            this.$message.error("请选择一条记录！");
            return;
          }
          let row =
            this.formData.kingInvoicePayableDetailEntities[this.currentIndex];
          row.bearDeptName = this.selectItem[0].deptName;
          this.formData.kingInvoicePayableDetailEntities[this.currentIndex];
          row.bearDeptCode = this.selectItem[0].deptCode;
          this.$set(
            this.formData.kingInvoicePayableDetailEntities,
            this.currentIndex,
            row
          );
          this.open = false;
        },
      };
      nameMap[this.dialogType] ? nameMap[this.dialogType]() : "";
    },

    //明细信息添加行
    addOrderDetails(e, type) {
      let obj = {
        baseUnit: "",
        batchNum: "",
        bearDeptCode: "",
        bearDeptName: "",
        createBy: "",
        createTime: "",
        deptId: "",
        discountAmount: "",
        discountRate: "",
        feeCode: "",
        feeName: "",
        id: "",
        inStorageNo: "",
        invoicePayableId: "",
        isGift: 0,
        isIncludeContractCost: 0,
        isIncludeProcureCost: 0,

        materialCode: "",
        materialId: "",
        materialName: "",
        notTaxAmount: "",
        notTaxAmountCurrency: "",
        num: "",
        orderId: "",
        outStorageNo: "",
        pageNo: 0,
        pageSize: 0,
        price: "",
        params: {},
        payableTaxPrice: "",
        rate: "",
        rateAmount: "",
        rateAmountCurrency: "",
        remark: "",
        searchValue: "",
        sourceDocType: this.sourceDocType,
        sourceId: "",
        sourceMaterialDetailId: "",
        taxPrice: "",
        totalTaxPrice: "",
        totalTaxPriceCurrency: "",
        unit: "",
        updateBy: "",
        updateTime: "",
        directRate: "",
        indirectRate: "",
        taxAmount: "",
      };
      if (e) {
        for (const key in obj) {
          if (e.hasOwnProperty(key)) {
            if (key === "id") {
              if (type === "edit") {
                obj.materialId = e.id;
              } else {
                obj.sourceMaterialDetailId = e.materialDetailId || "";
                obj.sourceRelationId = e.id;
              }
            } else {
              obj[key] = e[key];
            }
          }
        }
        if (type === "edit") {
          this.$set(
            this.formData.kingInvoicePayableDetailEntities,
            this.currentIndex,
            obj
          );
        } else {
          this.formData.kingInvoicePayableDetailEntities.push(obj);
        }
      } else {
        this.formData.kingInvoicePayableDetailEntities.push(obj);
      }
    },
    // 处理列表弹窗回显
    handleListBack(arr, type, isAllKey) {
      let obj = null;
      // arr.splice(this.currentIndex, 1);
      if (isAllKey) {
        this.selectItem.forEach((item) => {
          const nameMap = {
            detail: () => {
              obj = {
                baseUnit: "",
                batchNum: "",
                bearDeptCode: "",
                bearDeptName: "",
                createBy: "",
                createTime: "",
                deptId: "",
                discountAmount: "",
                discountRate: "",
                feeCode: "",
                feeName: "",
                id: "",
                inStorageNo: "",
                invoicePayableId: "",
                isGift: 0,
                isIncludeContractCost: 0,
                isIncludeProcureCost: 0,

                materialCode: "",
                materialId: "",
                materialName: "",
                notTaxAmount: "",
                notTaxAmountCurrency: "",
                num: "",
                orderId: "",
                outStorageNo: "",
                pageNo: 0,
                pageSize: 0,
                params: {},
                price: "",
                payableTaxPrice: "",
                rate: "",
                rateAmount: "",
                rateAmountCurrency: "",
                remark: "",
                searchValue: "",
                sourceDocType: this.sourceDocType,
                sourceId: "",
                sourceMaterialDetailId: "",
                taxPrice: "",
                totalTaxPrice: "",
                totalTaxPriceCurrency: "",
                unit: "",
                updateBy: "",
                updateTime: "",
                directRate: "",
                indirectRate: "",
                taxAmount: "",
              };
            },
            plan: () => {
              obj = {
                createBy: "",
                createTime: "",
                dueTime: "",
                id: "",
                invoiceReceivableId: "",

                pageNo: 0,
                pageSize: 0,
                params: {},
                receiptAmount: "",
                receiptRatio: "",
                remark: "",
                remarks: "",
                saleOrderId: "",
                searchValue: "",
                updateBy: "",
                updateTime: "",
              };
            },
            order: () => {
              obj = {
                businessType: "",
                changeReason: "",
                createBy: "",
                createTime: "",
                currency: "",
                customerId: "",
                customerName: "",
                delFlag: "",
                deliveryAddress: "",
                deliveryMethod: "",
                deptId: "",
                discountInfoId: "",
                id: "",
                instanceId: "",
                isTax: "",
                kingDocCode: "",
                kingDocTypeId: "",
                level: 0,
                margin: "",
                marginLevel: "",
                materialDetailList: [
                  {
                    amountMoney: "",
                    batchNum: "",
                    businessTaxCostPrice: "",
                    changeTime: "",
                    changeType: "",
                    createTime: "",
                    deliveryAddress: "",
                    deliveryDate: "",
                    deliveryLocation: "",
                    discountAmount: "",
                    discountRate: "",
                    executeStatus: "",
                    id: "",
                    inventoryId: "",
                    inventoryNum: 0,
                    inventoryUnit: "",
                    isGiveaway: true,

                    limit: 0,
                    material: {
                      allowAsset: "",
                      allowInventory: "",
                      allowOutsource: "",
                      allowProduce: "",
                      allowPurchase: "",
                      allowSale: "",
                      barCode: "",
                      brand: "",
                      businessType: "",
                      configurationProduction: "",
                      costPriceRatio: "",
                      createBy: "",
                      createTime: "",
                      dataState: "",
                      defaultTaxRate: "",
                      deptId: "",
                      disableBy: "",
                      examineBy: "",
                      examineTime: "",
                      grossWeight: "",
                      heightStr: "",
                      id: "",
                      imgUrl: "",
                      instanceId: "",
                      inventoryType: "",
                      isChange: "",

                      kit: "",
                      lengthStr: "",
                      materialCode: "",
                      materialDesc: "",
                      materialGroup: "",
                      materialInventoryEntity: {
                        batchInfo: "",
                        batchRule: "",
                        checkCycle: "",
                        convertDirection: "",
                        costUnit: "",
                        createBy: "",
                        createTime: "",
                        currency: "",
                        day: "",
                        economicOrderingBatch: "",
                        id: "",
                        inventoryUnit: "",
                        isBatch: "",
                        isCheck: "",
                        isLock: "",
                        isMaxInventory: "",
                        isMinInventory: "",
                        isOrderGoods: "",
                        isSafeInventory: "",
                        isTrueCheck: "",
                        materialId: "",
                        maxInventoyNum: "",
                        minInventoryNum: "",
                        orderGoodsNum: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        qualityManage: "",
                        qualityNum: "",
                        qualityUnit: "",
                        referenceCost: "",
                        remark: "",
                        safeInventoryNum: "",
                        searchValue: "",
                        serviceLife: "",
                        standardNumber: "",
                        supportUnit: "",
                        updateBy: "",
                        updateTime: "",
                        warePosition: "",
                        warehouseCode: "",
                      },
                      materialName: "",
                      materialPlanAttributeEntity: {
                        createBy: "",
                        createTime: "",
                        fAllowPartDelay: "",
                        fBaseVarLeadTimeLotSize: "",
                        fBaseVarLeadTimeLotSizeUnit: "",
                        fCanDelayDays: 0,
                        fCanLeadDays: 0,
                        fCheckLeadTime: 0,
                        fCheckLeadTimeType: "",
                        fDelayExtendDay: 0,
                        fFixLeadTime: 0,
                        fFixLeadTimeType: "",
                        fIncreaseQty: 0,
                        fIncreaseQtyUnit: "",
                        fIsMrpComBill: "",
                        fIsMrpComReq: "",
                        fLeadExtendDay: 0,
                        fMaxPoqty: 0,
                        fMfgPolicyId: "",
                        fMinPoqty: 0,
                        fMinPoqtyUnit: "",
                        fOrderIntervalTime: 0,
                        fOrderIntervalTimeType: "",
                        fOrderPolicy: "",
                        fPlanBatchSplitQty: "",
                        fPlanBatchSplitQtyUnit: "",
                        fPlanGroupId: "",
                        fPlanIdent: "",
                        fPlanIntervalsDays: 0,
                        fPlanOffsetTime: 0,
                        fPlanOffsetTimeType: "",
                        fPlanSafeStockQty: 0,
                        fPlanSafeStockQtyUnit: "",
                        fPlanTimeZone: 0,
                        fPlanWorkshop: "",
                        fPlanerId: "",
                        fPlanningStrategy: "",
                        fProScheTrackId: "",
                        fProductLine: "",
                        fRequestTimeZone: 0,
                        fSupplySourceId: "",
                        fVarLeadTime: 0,
                        fVarLeadTimeLotSize: "",
                        fVarLeadTimeLotSizeUnit: "",
                        fVarLeadTimeType: "",
                        fWriteOffQty: "",
                        fWriteOffQtyUnit: "",
                        id: "",
                        materialId: "",
                        maxPoqtyUnit: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        remark: "",
                        searchValue: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      materialProcureEntity: {
                        agentProcure: "",
                        barCodeRule: "",
                        createBy: "",
                        createTime: "",
                        dayProduction: 0,
                        dayProductionUnit: "",
                        defaultSupplier: "",
                        defunctProductionLine: "",
                        expenseItem: "",
                        id: "",
                        isControl: "",
                        isDayProduction: "",
                        isMaterialReturn: "",
                        isQuota: "",
                        isReq: "",
                        materialId: "",
                        minPackNum: "",
                        minSpiltNum: 0,
                        outsourcePricingUnit: "",
                        outsourceType: "",
                        outsourceUnit: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        procureGroup: "",
                        procureId: "",
                        procurePricingUnit: "",
                        procureType: "",
                        procureUnit: "",
                        quotaMode: "",
                        remark: "",
                        repeatPutNum: "",
                        searchValue: "",
                        takeOverDelay: 0,
                        takeOverDown: "",
                        takeOverLead: 0,
                        takeOverUp: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      materialProductEntity: {
                        createBy: "",
                        createTime: "",
                        deptId: "",
                        fBackFlushType: "",
                        fConsumVolatility: "",
                        fDefaultLineId: "",
                        fDefaultRouting: "",
                        fFinishReceiptOverRate: "",
                        fFinishReceiptShortRate: "",
                        fIsCompleteSet: "",
                        fIsEnableSchedule: "",
                        fIsKitting: "",
                        fIsMainPrd: "",
                        fIsMinissueQty: "",
                        fIsProductLine: "",
                        fIsSNCarryToParent: "",
                        fIssueType: "",
                        fMdlId: "",
                        fMdlMaterialId: "",
                        fMinissueQty: 0,
                        fMinissueUnitId: "",
                        fOrgTrustBillType: "",
                        fOverControlMode: "",
                        fPerUnitStandHour: "",
                        fPickBinId: "",
                        fPickStockId: "",
                        fProduceBillType: "",
                        fProduceUnitId: "",
                        fStandHourUnitId: "",
                        fStdLaborPrePareTime: "",
                        fStdLaborProcessTime: "",
                        fStdMachinePrepareTime: "",
                        fStdMachineProcessTime: "",
                        fWorkShopId: "",
                        fbkfltime: "",
                        fbomunitid: "",
                        ffixloss: "",
                        fisecn: "",
                        flosspercent: "",
                        id: "",
                        materialId: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        remark: "",
                        searchValue: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      materialProperty: "",
                      materialQualityEntity: {
                        createBy: "",
                        createTime: "",
                        fCheckDelivery: "",
                        fCheckEntrusted: "",
                        fCheckIncoming: "",
                        fCheckOther: "",
                        fCheckProduct: "",
                        fCheckReturn: "",
                        fCheckStock: "",
                        fCheckSubFtnMtrl: "",
                        fEWLeadDay: "",
                        fEnableCyclistQCSTK: "",
                        fEnableCyclistQcstkew: "",
                        fFirstQCControlType: "",
                        fIncQcSchemeId: "",
                        fIncSampSchemeId: "",
                        fInspectGroupId: "",
                        fInspectorId: "",
                        fIsFirstInspect: "",
                        fStockCycle: "",
                        id: "",
                        materialId: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        remark: "",
                        searchValue: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      materialSaleEntity: {
                        allowReleaseOrder: "",
                        allowReturns: "",
                        atpCheck: "",
                        controlSurpassUnit: "",
                        createBy: "",
                        createTime: "",
                        dropOutCount: "",
                        fisReturnPart: "",
                        fisaftersale: "",
                        fisproductfiles: "",
                        fiswarranted: "",
                        fwarranty: "",
                        fwarrantyunitid: "",
                        id: "",
                        isFavourableTax: "",
                        materialId: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        remark: "",
                        saleDownPrice: "",
                        saleGroup: "",
                        saleOutbound: "",
                        salePricingUnit: "",
                        saleUnit: "",
                        searchValue: "",
                        startOrderNum: 0,
                        surpassDown: "",
                        surpassUp: "",
                        taxType: "",
                        taxTypeCode: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      mnemonicCode: "",
                      model: "",
                      modelId: "",
                      netWeight: "",
                      oldMaterialCode: "",
                      pageNo: 0,
                      pageSize: 0,
                      params: {},
                      reasonForDisable: "",
                      remark: "",
                      searchValue: "",
                      sizeUnit: "",
                      state: "",
                      subItems: "",
                      taxType: "",
                      typeName: "",
                      unit: "",
                      updateBy: "",
                      updateTime: "",
                      volume: "",
                      weightUnit: "",
                      wideStr: "",
                    },
                    materialChangeEntity: {},
                    materialCode: "",
                    materialId: "",
                    netAmount: "",
                    noTaxMoney: "",
                    number: 0,
                    orderDelivery: {
                      batchNum: "",
                      bomVer: "",
                      changeTime: "",
                      controlDeliveryNum: true,
                      controlDeliveryTime: true,
                      createTime: "",
                      deliveryDelayDay: "",
                      deliveryDown: "",
                      deliveryEarlyTime: "",
                      deliveryLatestTime: "",
                      deliveryLeadDay: "",
                      deliveryUp: "",
                      id: "",

                      materialId: "",
                      materialName: "",
                      orderDeliveryDetails: [
                        {
                          address: "",
                          changeTime: "",
                          confirmComment: "",
                          confirmNum: "",
                          confirmTime: "",
                          createTime: "",
                          deliveredNum: "",
                          deliveryTime: "",
                          id: "",

                          location: "",
                          num: "",
                          orderDeliveryId: "",
                          orderId: "",
                          planUnit: "",
                          surplusNum: "",
                          userId: "",
                        },
                      ],
                      orderId: "",
                      receiveDept: "",
                      receiveOrg: "",
                      requireDept: "",
                      requireOrg: "",
                      supplierBatch: "",
                      supportAttr: "",
                      userId: "",
                    },
                    orderFinanceDetail: {
                      changeTime: "",
                      createTime: "",
                      discountAmount: "",
                      discountRate: "",
                      entryPriceInfo: "",
                      id: "",

                      materialCode: "",
                      materialId: "",
                      materialName: "",
                      netPrice: "",
                      orderId: "",
                      priceCeiling: "",
                      priceCoefficient: "",
                      priceFloor: "",
                      pricingNum: "",
                      pricingUnit: "",
                      settlementDept: "",
                      systemPricing: "",
                      taxRate: "",
                      unitPriceDiscount: "",
                      userId: "",
                    },
                    orderOther: {
                      businessClose: "",
                      businessFreeze: "",
                      businessProcess: "",
                      businessStop: "",
                      changeTime: "",
                      contractsCode: "",
                      createTime: "",
                      freezeName: "",
                      freezeTime: "",
                      id: "",
                      inventoryReturnNum: "",
                      isPlanConfirm: "",
                      isQuotaGeneration: "",

                      materialCode: "",
                      materialId: "",
                      materialName: "",
                      materialReceivedReturnNum: "",
                      orderId: "",
                      planTrackingCode: "",
                      requireDocCode: "",
                      requireDocLineCode: "",
                      requireFrom: "",
                      requireTrackingCode: "",
                      sourceDocCode: "",
                      sourceDocType: this.sourceDocType,
                      stopName: "",
                      stopTime: "",
                      surplusInboundNum: "",
                      surplusMaterialReceivedNum: "",
                      totalInboundNum: "",
                      totalMaterialReceivedNum: "",
                      totalMaterialReturnNum: "",
                      updateFlag: "",
                      userId: "",
                    },
                    originalContainsTaxPrice: "",
                    originalNumber: "",
                    page: 0,
                    parentMaterial: "",
                    price: "",
                    pricingNum: "",
                    pricingUnit: "",
                    purchaseUnit: "",
                    ramarks: "",
                    receivedFirstTicketsNum: "",
                    receivingDept: "",
                    relationId: "",
                    requireDept: "",
                    saleOrderDelivery: {
                      createBy: "",
                      createTime: "",
                      deliveryDown: "",
                      deliveryType: "",
                      deliveryUnit: "",
                      deliveryUp: "",
                      id: "",
                      inventoryDept: "",

                      materialCode: "",
                      materialName: "",
                      orderId: "",
                      pageNo: 0,
                      pageSize: 0,
                      params: {},
                      remark: "",
                      saleOrderDeliveryDetailEntities: [
                        {
                          createBy: "",
                          createTime: "",
                          deliveryAddress: "",
                          deliveryAddressDetail: "",
                          deliveryDate: "",
                          deliveryId: "",
                          id: "",
                          inAdvance: "",

                          pageNo: 0,
                          pageSize: 0,
                          params: {},
                          planDeliveryDate: "",
                          remark: "",
                          saleNum: "",
                          saleUnit: "",
                          searchValue: "",
                          updateBy: "",
                          updateTime: "",
                        },
                      ],
                      searchValue: "",
                      updateBy: "",
                      updateTime: "",
                    },
                    settlementDept: "",
                    sourceDocCode: "",
                    sourceDocType: this.sourceDocType,
                    sourceRelationId: "",
                    supplierMaterialCode: "",
                    supplierMaterialName: "",
                    taxAmount: "",
                    taxMoney: "",
                    taxPrice: "",
                    taxRate: "",
                    token: "",
                    totalAcceptanceAmount: "",
                    totalAcceptanceRate: "",
                    totalTaxPrice: "",
                    type: 0,
                    warehouseId: "",
                    warehouseRegionId: "",
                  },
                ],
                modelId: "",
                originalOrderCode: "",
                pageNo: 0,
                pageSize: 0,
                params: {},
                parentId: "",
                payer: "",
                paymentTerms: "",
                priceTax: "",
                priceinfoId: "",
                rate: "",
                rateType: "",
                receivingParty: "",
                remark: "",
                saleCode: "",
                saleDate: "",
                saleDept: "",
                saleGroup: "",
                saleId: "",
                searchValue: "",
                settlementParty: "",
                settlementType: "",
                shippingAddress: "",
                shippingPerson: "",
                shippingPersonName: "",
                shippingPhone: "",
                sourceDocType: this.sourceDocType,
                sourceDocTypeName: "",
                state: "",
                taxAmount: "",
                updateBy: "",
                updateState: "",
                updateTime: "",
                valueTax: "",
              };
            },
            storage: () => {
              obj = {
                batchNumber: "",
                changeTime: "",
                contractId: "",
                createTime: "",
                id: "",
                inOutTime: "",
                inStorageType: 0,
                instanceId: 0,

                limit: 0,
                orderId: "",
                page: 0,
                projectId: "",
                purchaseCode: "",
                remarks: "",
                state: 0,
                supplierId: "",
                token: "",
                type: 0,
                useUserId: "",
                warehouseId: "",
                warehouseRegionId: "",
              };
            },
          };
          nameMap[type] ? nameMap[type]() : "";
          Object.keys(item).forEach((itemKey) => {
            Object.keys(obj).forEach((materialKey) => {
              if (itemKey === materialKey) {
                obj[materialKey] = item[itemKey];
              }
              if (itemKey === "id") {
                obj["id"] = "";
              }
            });
          });
          this.$set(
            this.formData.kingInvoicePayableDetailEntities,
            this.currentIndex,
            obj
          );
        });
      } else {
        this.selectItem.forEach((item) => {
          const nameMap = {
            detail: () => {
              obj = {
                createBy: "",
                createTime: "",
                discountAmount: "",
                discountRate: "",
                feeBearDeptId: "",
                feeCode: "",
                feeId: "",
                id: "",
                inOutStorageId: "",
                invoiceReceivableId: "",

                materialCode: "",
                materialId: "",
                materialName: "",
                notTaxAmount: "",
                num: "",
                pageNo: 0,
                pageSize: 0,
                params: {},
                price: "",
                rate: "",
                rateAmount: "",
                remark: "",
                saleOrderId: "",
                searchValue: "",
                sourceDocId: "",
                sourceDocType: this.sourceDocType,
                taxPrice: "",
                unit: "",
                updateBy: "",
                updateTime: "",
              };

              item.title ? (obj.feeId = item.title) : ""; //费用项目名称
              item.feeCode ? (obj.feeCode = item.feeCode) : ""; //费用项目编码
            },
            plan: () => {
              obj = {
                createBy: "",
                createTime: "",
                dueTime: "",
                id: "",
                invoiceReceivableId: "",

                pageNo: 0,
                pageSize: 0,
                params: {},
                receiptAmount: "",
                receiptRatio: "",
                remark: "",
                remarks: "",
                saleOrderId: "",
                searchValue: "",
                updateBy: "",
                updateTime: "",
              };
            },
            order: () => {
              obj = {
                businessType: "",
                changeReason: "",
                createBy: "",
                createTime: "",
                currency: "",
                customerId: "",
                customerName: "",
                delFlag: "",
                deliveryAddress: "",
                deliveryMethod: "",
                deptId: "",
                discountInfoId: "",
                id: "",
                instanceId: "",
                isTax: "",
                kingDocCode: "",
                kingDocTypeId: "",
                level: 0,
                margin: "",
                marginLevel: "",
                materialDetailList: [
                  {
                    amountMoney: "",
                    batchNum: "",
                    businessTaxCostPrice: "",
                    changeTime: "",
                    changeType: "",
                    createTime: "",
                    deliveryAddress: "",
                    deliveryDate: "",
                    deliveryLocation: "",
                    discountAmount: "",
                    discountRate: "",
                    executeStatus: "",
                    id: "",
                    inventoryId: "",
                    inventoryNum: 0,
                    inventoryUnit: "",
                    isGiveaway: true,

                    limit: 0,
                    material: {
                      allowAsset: "",
                      allowInventory: "",
                      allowOutsource: "",
                      allowProduce: "",
                      allowPurchase: "",
                      allowSale: "",
                      barCode: "",
                      brand: "",
                      businessType: "",
                      configurationProduction: "",
                      costPriceRatio: "",
                      createBy: "",
                      createTime: "",
                      dataState: "",
                      defaultTaxRate: "",
                      deptId: "",
                      disableBy: "",
                      examineBy: "",
                      examineTime: "",
                      grossWeight: "",
                      heightStr: "",
                      id: "",
                      imgUrl: "",
                      instanceId: "",
                      inventoryType: "",
                      isChange: "",

                      kit: "",
                      lengthStr: "",
                      materialCode: "",
                      materialDesc: "",
                      materialGroup: "",
                      materialInventoryEntity: {
                        batchInfo: "",
                        batchRule: "",
                        checkCycle: "",
                        convertDirection: "",
                        costUnit: "",
                        createBy: "",
                        createTime: "",
                        currency: "",
                        day: "",
                        economicOrderingBatch: "",
                        id: "",
                        inventoryUnit: "",
                        isBatch: "",
                        isCheck: "",
                        isLock: "",
                        isMaxInventory: "",
                        isMinInventory: "",
                        isOrderGoods: "",
                        isSafeInventory: "",
                        isTrueCheck: "",
                        materialId: "",
                        maxInventoyNum: "",
                        minInventoryNum: "",
                        orderGoodsNum: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        qualityManage: "",
                        qualityNum: "",
                        qualityUnit: "",
                        referenceCost: "",
                        remark: "",
                        safeInventoryNum: "",
                        searchValue: "",
                        serviceLife: "",
                        standardNumber: "",
                        supportUnit: "",
                        updateBy: "",
                        updateTime: "",
                        warePosition: "",
                        warehouseCode: "",
                      },
                      materialName: "",
                      materialPlanAttributeEntity: {
                        createBy: "",
                        createTime: "",
                        fAllowPartDelay: "",
                        fBaseVarLeadTimeLotSize: "",
                        fBaseVarLeadTimeLotSizeUnit: "",
                        fCanDelayDays: 0,
                        fCanLeadDays: 0,
                        fCheckLeadTime: 0,
                        fCheckLeadTimeType: "",
                        fDelayExtendDay: 0,
                        fFixLeadTime: 0,
                        fFixLeadTimeType: "",
                        fIncreaseQty: 0,
                        fIncreaseQtyUnit: "",
                        fIsMrpComBill: "",
                        fIsMrpComReq: "",
                        fLeadExtendDay: 0,
                        fMaxPoqty: 0,
                        fMfgPolicyId: "",
                        fMinPoqty: 0,
                        fMinPoqtyUnit: "",
                        fOrderIntervalTime: 0,
                        fOrderIntervalTimeType: "",
                        fOrderPolicy: "",
                        fPlanBatchSplitQty: "",
                        fPlanBatchSplitQtyUnit: "",
                        fPlanGroupId: "",
                        fPlanIdent: "",
                        fPlanIntervalsDays: 0,
                        fPlanOffsetTime: 0,
                        fPlanOffsetTimeType: "",
                        fPlanSafeStockQty: 0,
                        fPlanSafeStockQtyUnit: "",
                        fPlanTimeZone: 0,
                        fPlanWorkshop: "",
                        fPlanerId: "",
                        fPlanningStrategy: "",
                        fProScheTrackId: "",
                        fProductLine: "",
                        fRequestTimeZone: 0,
                        fSupplySourceId: "",
                        fVarLeadTime: 0,
                        fVarLeadTimeLotSize: "",
                        fVarLeadTimeLotSizeUnit: "",
                        fVarLeadTimeType: "",
                        fWriteOffQty: "",
                        fWriteOffQtyUnit: "",
                        id: "",
                        materialId: "",
                        maxPoqtyUnit: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        remark: "",
                        searchValue: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      materialProcureEntity: {
                        agentProcure: "",
                        barCodeRule: "",
                        createBy: "",
                        createTime: "",
                        dayProduction: 0,
                        dayProductionUnit: "",
                        defaultSupplier: "",
                        defunctProductionLine: "",
                        expenseItem: "",
                        id: "",
                        isControl: "",
                        isDayProduction: "",
                        isMaterialReturn: "",
                        isQuota: "",
                        isReq: "",
                        materialId: "",
                        minPackNum: "",
                        minSpiltNum: 0,
                        outsourcePricingUnit: "",
                        outsourceType: "",
                        outsourceUnit: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        procureGroup: "",
                        procureId: "",
                        procurePricingUnit: "",
                        procureType: "",
                        procureUnit: "",
                        quotaMode: "",
                        remark: "",
                        repeatPutNum: "",
                        searchValue: "",
                        takeOverDelay: 0,
                        takeOverDown: "",
                        takeOverLead: 0,
                        takeOverUp: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      materialProductEntity: {
                        createBy: "",
                        createTime: "",
                        deptId: "",
                        fBackFlushType: "",
                        fConsumVolatility: "",
                        fDefaultLineId: "",
                        fDefaultRouting: "",
                        fFinishReceiptOverRate: "",
                        fFinishReceiptShortRate: "",
                        fIsCompleteSet: "",
                        fIsEnableSchedule: "",
                        fIsKitting: "",
                        fIsMainPrd: "",
                        fIsMinissueQty: "",
                        fIsProductLine: "",
                        fIsSNCarryToParent: "",
                        fIssueType: "",
                        fMdlId: "",
                        fMdlMaterialId: "",
                        fMinissueQty: 0,
                        fMinissueUnitId: "",
                        fOrgTrustBillType: "",
                        fOverControlMode: "",
                        fPerUnitStandHour: "",
                        fPickBinId: "",
                        fPickStockId: "",
                        fProduceBillType: "",
                        fProduceUnitId: "",
                        fStandHourUnitId: "",
                        fStdLaborPrePareTime: "",
                        fStdLaborProcessTime: "",
                        fStdMachinePrepareTime: "",
                        fStdMachineProcessTime: "",
                        fWorkShopId: "",
                        fbkfltime: "",
                        fbomunitid: "",
                        ffixloss: "",
                        fisecn: "",
                        flosspercent: "",
                        id: "",
                        materialId: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        remark: "",
                        searchValue: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      materialProperty: "",
                      materialQualityEntity: {
                        createBy: "",
                        createTime: "",
                        fCheckDelivery: "",
                        fCheckEntrusted: "",
                        fCheckIncoming: "",
                        fCheckOther: "",
                        fCheckProduct: "",
                        fCheckReturn: "",
                        fCheckStock: "",
                        fCheckSubFtnMtrl: "",
                        fEWLeadDay: "",
                        fEnableCyclistQCSTK: "",
                        fEnableCyclistQcstkew: "",
                        fFirstQCControlType: "",
                        fIncQcSchemeId: "",
                        fIncSampSchemeId: "",
                        fInspectGroupId: "",
                        fInspectorId: "",
                        fIsFirstInspect: "",
                        fStockCycle: "",
                        id: "",
                        materialId: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        remark: "",
                        searchValue: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      materialSaleEntity: {
                        allowReleaseOrder: "",
                        allowReturns: "",
                        atpCheck: "",
                        controlSurpassUnit: "",
                        createBy: "",
                        createTime: "",
                        dropOutCount: "",
                        fisReturnPart: "",
                        fisaftersale: "",
                        fisproductfiles: "",
                        fiswarranted: "",
                        fwarranty: "",
                        fwarrantyunitid: "",
                        id: "",
                        isFavourableTax: "",
                        materialId: "",
                        pageNo: 0,
                        pageSize: 0,
                        params: {},
                        remark: "",
                        saleDownPrice: "",
                        saleGroup: "",
                        saleOutbound: "",
                        salePricingUnit: "",
                        saleUnit: "",
                        searchValue: "",
                        startOrderNum: 0,
                        surpassDown: "",
                        surpassUp: "",
                        taxType: "",
                        taxTypeCode: "",
                        updateBy: "",
                        updateTime: "",
                      },
                      mnemonicCode: "",
                      model: "",
                      modelId: "",
                      netWeight: "",
                      oldMaterialCode: "",
                      pageNo: 0,
                      pageSize: 0,
                      params: {},
                      reasonForDisable: "",
                      remark: "",
                      searchValue: "",
                      sizeUnit: "",
                      state: "",
                      subItems: "",
                      taxType: "",
                      typeName: "",
                      unit: "",
                      updateBy: "",
                      updateTime: "",
                      volume: "",
                      weightUnit: "",
                      wideStr: "",
                    },
                    materialChangeEntity: {},
                    materialCode: "",
                    materialId: "",
                    netAmount: "",
                    noTaxMoney: "",
                    number: 0,
                    orderDelivery: {
                      batchNum: "",
                      bomVer: "",
                      changeTime: "",
                      controlDeliveryNum: true,
                      controlDeliveryTime: true,
                      createTime: "",
                      deliveryDelayDay: "",
                      deliveryDown: "",
                      deliveryEarlyTime: "",
                      deliveryLatestTime: "",
                      deliveryLeadDay: "",
                      deliveryUp: "",
                      id: "",

                      materialId: "",
                      materialName: "",
                      orderDeliveryDetails: [
                        {
                          address: "",
                          changeTime: "",
                          confirmComment: "",
                          confirmNum: "",
                          confirmTime: "",
                          createTime: "",
                          deliveredNum: "",
                          deliveryTime: "",
                          id: "",

                          location: "",
                          num: "",
                          orderDeliveryId: "",
                          orderId: "",
                          planUnit: "",
                          surplusNum: "",
                          userId: "",
                        },
                      ],
                      orderId: "",
                      receiveDept: "",
                      receiveOrg: "",
                      requireDept: "",
                      requireOrg: "",
                      supplierBatch: "",
                      supportAttr: "",
                      userId: "",
                    },
                    orderFinanceDetail: {
                      changeTime: "",
                      createTime: "",
                      discountAmount: "",
                      discountRate: "",
                      entryPriceInfo: "",
                      id: "",

                      materialCode: "",
                      materialId: "",
                      materialName: "",
                      netPrice: "",
                      orderId: "",
                      priceCeiling: "",
                      priceCoefficient: "",
                      priceFloor: "",
                      pricingNum: "",
                      pricingUnit: "",
                      settlementDept: "",
                      systemPricing: "",
                      taxRate: "",
                      unitPriceDiscount: "",
                      userId: "",
                    },
                    orderOther: {
                      businessClose: "",
                      businessFreeze: "",
                      businessProcess: "",
                      businessStop: "",
                      changeTime: "",
                      contractsCode: "",
                      createTime: "",
                      freezeName: "",
                      freezeTime: "",
                      id: "",
                      inventoryReturnNum: "",
                      isPlanConfirm: "",
                      isQuotaGeneration: "",

                      materialCode: "",
                      materialId: "",
                      materialName: "",
                      materialReceivedReturnNum: "",
                      orderId: "",
                      planTrackingCode: "",
                      requireDocCode: "",
                      requireDocLineCode: "",
                      requireFrom: "",
                      requireTrackingCode: "",
                      sourceDocCode: "",
                      sourceDocType: this.sourceDocType,
                      stopName: "",
                      stopTime: "",
                      surplusInboundNum: "",
                      surplusMaterialReceivedNum: "",
                      totalInboundNum: "",
                      totalMaterialReceivedNum: "",
                      totalMaterialReturnNum: "",
                      updateFlag: "",
                      userId: "",
                    },
                    originalContainsTaxPrice: "",
                    originalNumber: "",
                    page: 0,
                    parentMaterial: "",
                    price: "",
                    pricingNum: "",
                    pricingUnit: "",
                    purchaseUnit: "",
                    ramarks: "",
                    receivedFirstTicketsNum: "",
                    receivingDept: "",
                    relationId: "",
                    requireDept: "",
                    saleOrderDelivery: {
                      createBy: "",
                      createTime: "",
                      deliveryDown: "",
                      deliveryType: "",
                      deliveryUnit: "",
                      deliveryUp: "",
                      id: "",
                      inventoryDept: "",

                      materialCode: "",
                      materialName: "",
                      orderId: "",
                      pageNo: 0,
                      pageSize: 0,
                      params: {},
                      remark: "",
                      saleOrderDeliveryDetailEntities: [
                        {
                          createBy: "",
                          createTime: "",
                          deliveryAddress: "",
                          deliveryAddressDetail: "",
                          deliveryDate: "",
                          deliveryId: "",
                          id: "",
                          inAdvance: "",

                          pageNo: 0,
                          pageSize: 0,
                          params: {},
                          planDeliveryDate: "",
                          remark: "",
                          saleNum: "",
                          saleUnit: "",
                          searchValue: "",
                          updateBy: "",
                          updateTime: "",
                        },
                      ],
                      searchValue: "",
                      updateBy: "",
                      updateTime: "",
                    },
                    settlementDept: "",
                    sourceDocCode: "",
                    sourceDocType: this.sourceDocType,
                    sourceRelationId: "",
                    supplierMaterialCode: "",
                    supplierMaterialName: "",
                    taxAmount: "",
                    taxMoney: "",
                    taxPrice: "",
                    taxRate: "",
                    token: "",
                    totalAcceptanceAmount: "",
                    totalAcceptanceRate: "",
                    totalTaxPrice: "",
                    type: 0,
                    warehouseId: "",
                    warehouseRegionId: "",
                  },
                ],
                modelId: "",
                originalOrderCode: "",
                pageNo: 0,
                pageSize: 0,
                params: {},
                parentId: "",
                payer: "",
                paymentTerms: "",
                priceTax: "",
                priceinfoId: "",
                rate: "",
                rateType: "",
                receivingParty: "",
                remark: "",
                saleCode: "",
                saleDate: "",
                saleDept: "",
                saleGroup: "",
                saleId: "",
                searchValue: "",
                settlementParty: "",
                settlementType: "",
                shippingAddress: "",
                shippingPerson: "",
                shippingPersonName: "",
                shippingPhone: "",
                sourceDocType: this.sourceDocType,
                sourceDocTypeName: "",
                state: "",
                taxAmount: "",
                updateBy: "",
                updateState: "",
                updateTime: "",
                valueTax: "",
              };
            },
            storage: () => {
              obj = {
                batchNumber: "",
                changeTime: "",
                contractId: "",
                createTime: "",
                id: "",
                inOutTime: "",
                inStorageType: 0,
                instanceId: 0,
                limit: 0,
                orderId: "",
                page: 0,
                projectId: "",
                purchaseCode: "",
                remarks: "",
                state: 0,
                supplierId: "",
                token: "",
                type: 0,
                useUserId: "",
                warehouseId: "",
                warehouseRegionId: "",
              };
            },
          };
          nameMap[type] ? nameMap[type]() : "";
          arr.push(obj);
        });
      }
    },
    // 单据类型 级联选择器
    handleInvoiceChange(val) {
      this.$set(this.formData.kingInvoicePayableEntity, "docTypeCode", val);
      this.docType = val;
      this.formData.kingInvoicePayableDetailEntities = [];
      // if (val === "YFD01_SYS") {
      //   // 标准应付单
      //   this.docTypeExpanse = "";
      // } else if (val === "YFD02_SYS") {
      //   // 费用应付单
      //   this.docTypeStandard = "";
      // } else {
      //   this.docTypeStandard = "";
      //   this.docTypeExpanse = "";
      // }
    },
    //切换单据类型
    // changeDocType() {
    //   this.formData.kingInvoicePayableDetailEntities = [];
    //   if (this.docType === "YFD01_SYS") {
    //     // 标准应付单
    //     this.docTypeStandard = this.docType;
    //     this.docTypeExpanse = "";
    //   } else if (this.docType === "YFD02_SYS") {
    //     // 费用应付单
    //     this.docTypeExpanse = this.docType;
    //     this.docTypeStandard = "";
    //   } else {
    //     this.docTypeStandard = "";
    //     this.docTypeExpanse = "";
    //   }
    //   this.docTypeShow = false;
    // },
    // 基础表单提交
    submit() {
      const cb = (res) => {
        const obj = {
          id: res.data,
          businessType: "13",
          modelId: this.$store.state.workflow.businessConfig.id,
        };
        addInfo(obj).then((res) => {
          if (res.code === 200) {
            this.$store.commit("workflow/SET_BUSINESSDRAWER", false);
            this.$message({
              message: "提交成功！",
              type: "success",
            });
          }
        });
      };
      this.temporaryStorage(cb);
    },
    //暂存
    temporaryStorage(cb) {
      this.$refs["formRef"].validate((valid) => {
        if (!valid) {
          this.$message.error("请填写完整信息！");
          return;
        }
        // TODO 提交表单

        addInfoTemporary(this.formData).then((res) => {
          if (res.code === 200) {
            if (cb) {
              cb(res);
              return;
            }
            this.$store.commit("workflow/SET_BUSINESSDRAWER", false);
            this.$message({
              message: "暂存成功！",
              type: "success",
            });
          }
        });
      });
    },
    //获取单据类型
    getDocTypeListApi() {
      getDocTypeList({ docCode: "YFKGL00000006" }).then((res) => {
        if (res.code === 200) {
          this.documentTypeList = res.rows;
          if (res.rows.length) {
            this.docType = res.rows[0].docCode;
            this.handleInvoiceChange(res.rows[0].docCode);
            // this.changeDocType();
          }
        }
      });
    },

    //折扣率改变
    discountRateChange(row, index) {
      this.$set(
        this.formData.kingInvoicePayableDetailEntities[index],
        "discountAmount",
        (row.taxPrice * row.num * row.discountRate) / 100
      );
      const discountAmount =
        this.formData.kingInvoicePayableDetailEntities.reduce((total, item) => {
          return total + item.discountAmount * 1;
        }, 0);
      this.$set(
        this.formData.kingInvoicePayableEntity,
        "discountAmount",
        discountAmount
      );
    },

    //基础数据汇率改变
    changeRate(val) {
      if (!val) {
        return;
      }
      console.log("val", val);
      if (this.formData.kingInvoicePayableDetailEntities.length) {
        this.formData.kingInvoicePayableDetailEntities.forEach((row, index) => {
          if (row.num && val && row.totalTaxPrice && row.rate) {
            let totalTaxAmount = row.totalTaxPrice;
            let number = row.num;
            let taxRate = row.rate;
            let rate = val;
            getCompute({ number, taxRate, totalTaxAmount, rate }).then(
              (res) => {
                // 单价
                this.$set(
                  this.formData.kingInvoicePayableDetailEntities[index],
                  "price",
                  res.data.price
                );
                // 金额
                this.$set(
                  this.formData.kingInvoicePayableDetailEntities[index],
                  "amountMoney",
                  res.data.amount
                );
                // 税额
                this.$set(
                  this.formData.kingInvoicePayableDetailEntities[index],
                  "rateAmount",
                  res.data.taxAmount
                );
                // 含税单价
                this.$set(
                  this.formData.kingInvoicePayableDetailEntities[index],
                  "taxPrice",
                  res.data.taxUnitPrice
                );
              }
            );
          }
        });
      }
    },
    // 计算值
    caculateNum(row, index, type) {
      if (type === "discountAmount") {
        const discountAmount =
          this.formData.kingInvoicePayableDetailEntities.reduce(
            (total, item) => {
              return total + item.discountAmount * 1;
            },
            0
          );
        this.$set(
          this.formData.kingInvoicePayableEntity,
          "discountAmount",
          discountAmount
        );
        return;
      }
      //基础价税合计
      if (type === "totalTaxPrice") {
        const totalTaxAmount =
          this.formData.kingInvoicePayableDetailEntities.reduce(
            (total, item) => {
              return total + item.totalTaxPrice * 1;
            },
            0
          );
        this.$set(
          this.formData.kingInvoicePayableEntity,
          "totalTaxAmount",
          totalTaxAmount
        );
      }
      console.log(
        "caculateNum",
        row.num,
        this.formData.kingInvoicePayableEntity.rate,
        row.totalTaxPrice,
        row.rate
      );

      if (
        row.num &&
        row.rate &&
        row.totalTaxPrice &&
        this.formData.kingInvoicePayableEntity.rate
      ) {
        let totalTaxAmount = row.totalTaxPrice;
        let number = row.num;
        let taxRate = row.rate;
        let rate = this.formData.kingInvoicePayableEntity.rate;
        getCompute({ number, taxRate, totalTaxAmount, rate }).then((res) => {
          // 单价
          this.$set(
            this.formData.kingInvoicePayableDetailEntities[index],
            "price",
            res.data.price
          );
          // 金额
          this.$set(
            this.formData.kingInvoicePayableDetailEntities[index],
            "amountMoney",
            res.data.amount
          );
          // 税额
          this.$set(
            this.formData.kingInvoicePayableDetailEntities[index],
            "rateAmount",
            res.data.taxAmount
          );
          // 含税单价
          this.$set(
            this.formData.kingInvoicePayableDetailEntities[index],
            "taxPrice",
            res.data.taxUnitPrice
          );
        });
      }
    },
    //下拉类型选择
    handleCommand(val) {
      this.dialog = true;
      this.showDialog(val);
      if (val === "payOrder") {
        this.sourceDocType = "2";
        this.$set(this.formData.kingInvoicePayableEntity, "accountType", "2");
      } else if (val === "purchaseOrder") {
        this.sourceDocType = "3";
      } else if (val === "backOrder") {
        this.sourceDocType = "4";
      } else if (val === "spilloverOrder") {
        this.sourceDocType = "5";
      }
    },
    //费用应付单明细进出库checkbox
    inOutChange(type, row, index) {
      if (type === 1) {
        if (row.isIncludeProcureCost) {
          row.isIncludeContractCost = false;
          row.outStorageNo = "";
        }
      } else {
        if (row.isIncludeProcureCost) {
          row.isIncludeProcureCost = false;
          row.inStorageNo = "";
        }
      }
      this.$set(this.formData.kingInvoicePayableDetailEntities, index, row);
    },
  },
  created() {
    if (!this.rowId) {
      this.getDocTypeListApi();
    }
  },
};
</script>
<style lang="scss" scoped></style>
